import type { RouteRecordRaw } from 'vue-router'

export const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'MainLayout',
    component: () => import('@/components/layout/MainLayout.vue'), // 主布局组件
    redirect: '/statistic/overview', // 默认跳转仪表盘
    meta: {
      requiresAuth: true, // 标记需要登录权限（路由守卫用）
    },
    children: [
      // 统计报表
      {
        path: 'statistic/overview',
        name: 'StatisticOverview',
        component: () => import('@/views/statistic/overview/index.vue'),
        meta: {
          title: '概述', // 页面标题（用于面包屑/标签页）
        },
      },
      {
        path: 'statistic/hot-question',
        name: 'StatisticHotQuestion',
        component: () => import('@/views/statistic/hot_question/index.vue'),
        meta: {
          title: '热门问题',
        },
      },
      {
        path: 'statistic/hot-vocabulary',
        name: 'StatisticHotVocabulary',
        component: () => import('@/views/statistic/hot_vocabulary/index.vue'),
        meta: {
          title: '热门词汇',
        },
      },

      // 知识管理
      {
        path: 'knowledge/corpus',
        name: 'KnowledgeCorpus',
        component: () => import('@/views/knowledge/corpus/index.vue'),
        meta: {
          title: '语料管理',
        },
      },
      {
        path: 'knowledge/corpus/detail',
        name: 'KnowledgeCorpusDetail',
        component: () => import('@/views/knowledge/corpus/detail/index.vue'),
        meta: {
          title: '语料管理 - 详情',
        },
      },
      {
        path: 'knowledge/awaiting-corpus',
        name: 'KnowledgeAwaitingCorpus',
        component: () => import('@/views/knowledge/awaiting_corpus/index.vue'),
        meta: {
          title: '待入库语料',
        },
      },
      {
        path: 'knowledge/upload-corpus',
        name: 'KnowledgeUploadCorpus',
        component: () => import('@/views/knowledge/upload_corpus/index.vue'),
        meta: {
          title: '语料包上传',
        },
      },

      // 对话历史
      {
        path: 'dialogue/query',
        name: 'DialogueQuery',
        component: () => import('@/views/dialogue/query/index.vue'),
        meta: {
          title: '查询',
        },
      },
      {
        path: 'dialogue/download',
        name: 'DialogueDownload',
        component: () => import('@/views/dialogue/download/index.vue'),
        meta: {
          title: '下载',
        },
      },

      // 机器人设置
      {
        path: 'robot/basic-setting',
        name: 'RobotBasicSetting',
        component: () => import('@/views/robot/basic_setting/index.vue'),
        meta: {
          title: '基础设置',
        },
      },
      {
        path: 'robot/advanced-setting',
        name: 'RobotAdvancedSetting',
        component: () => import('@/views/robot/advanced_setting/index.vue'),
        meta: {
          title: '高级设置',
        },
      },
      {
        path: 'robot/custom-task',
        name: 'RobotCustomTask',
        component: () => import('@/views/robot/custom_task/index.vue'),
        meta: {
          title: '自定义任务',
        },
      },
      {
        path: 'robot/online-management',
        name: 'RobotOnlineManagement',
        component: () => import('@/views/robot/online_management/index.vue'),
        meta: {
          title: '上线管理',
        },
      },

      // 接入管理
      {
        path: 'access',
        name: 'AccessIndex',
        component: () => import('@/views/access/index.vue'),
        meta: {
          title: '接入管理',
        },
      },

      // 账号管理
      {
        path: 'account',
        name: 'AccountIndex',
        component: () => import('@/views/account/index.vue'),
        meta: {
          title: '账号管理',
        },
      },
    ],
  },
  {
    path: '/about',
    name: 'AboutIndex',
    component: () => import('@/views/about/index.vue'),
  },
  // 404 路由必须放在最后
  {
    path: '/:pathMatch(.*)*', // 捕获所有未匹配的路由
    name: 'NotFoundIndex',
    component: () => import('@/views/404/index.vue'),
  },
]
